package com.fitsoftwareprocess.mobilemap.bus;

import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;


public class Service 
{
	private MyWebClient _MyWebClient;
	private String _Url;
	
	
	public Service(String NameSpace, String Url)
	{
		_MyWebClient = new MyWebClient(NameSpace);
		this._Url = Url;
	}
	
	public String getService1(String chuoitimkiem)
	{
		String methodName = "GetListService1";
		SoapObject req = _MyWebClient.GetSoapObject(methodName);
		req.addProperty("keyword", chuoitimkiem);
		SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
		SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);
		String DataString = soapResult.toString();
		return DataString;
	}
	
	public String getServiceAround(String chuoitimkiem)// tim kiem tat cac cac dich vu theo chuoi tim kiem
	{
		String methodName = "GetListServiceAround";
		SoapObject req = _MyWebClient.GetSoapObject(methodName);
		req.addProperty("keyword", chuoitimkiem);
		SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
		SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);
		String DataString = soapResult.toString();
		return DataString;
	}
	
	public String getServiceByDistanceAndType(String type, String area)// tim kiem tat cac cac dich vu theo chuoi tim kiem
	{
		String methodName = "getPlaceByDistanceAndType";
		SoapObject req = _MyWebClient.GetSoapObject(methodName);
		req.addProperty("type", type);
		req.addProperty("area", area);
		SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
		SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);
		String DataString = soapResult.toString();
		return DataString;
	}
	
	public String getServiceAroundWithPoint(String longitude , String latitude)
	{
		String methodName = "GetListServiceAroundWithPoint";
		SoapObject req = _MyWebClient.GetSoapObject(methodName);
		req.addProperty("longitude", longitude);
		req.addProperty("latitude", latitude);
		SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
		SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);
		String DataString = soapResult.toString();
		return DataString;
	}
	
	public String getServiceByDistance(String latitude,String longitude)
	{
		String methodName = "getPlaceByDistance";
		SoapObject req = _MyWebClient.GetSoapObject(methodName);
		req.addProperty("vido1", latitude);
		req.addProperty("kinhdo1", longitude);
		
		SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
		SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);
		String DataString = soapResult.toString();
		return DataString;
	}
	
	 public void Addservice(String ten,String diachi,String Loaidichvu,String vido,String kinhdo)
		{
			String methodName = "Addservice";
			SoapObject req = _MyWebClient.GetSoapObject(methodName);
			req.addProperty("ten",ten );
			req.addProperty("diachi",diachi );
			req.addProperty("Loaidichvu",Loaidichvu);
			req.addProperty("vido",vido);
			req.addProperty("kinhdo",kinhdo );
			SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
			SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);

		}
	 
	 public void deleteService(String id)
		{
			String methodName = "deleteService";
			SoapObject req = _MyWebClient.GetSoapObject(methodName);
			req.addProperty("id",id );;
			SoapSerializationEnvelope envelope = _MyWebClient.GetEnvelope(req);
			SoapPrimitive soapResult = _MyWebClient.MakeCall(_Url, envelope, _MyWebClient.getNameSpace(), methodName);

		}
	
	
	
	
	
}
